'''
Created on 15-Jul-2010

@author: dexen
'''

import time
import random

import dexen

import myind, constants

def random_genotype(size):
    genotype = []
    for _ in range(size):
        genotype.append(random.random())
    return genotype

def generate_ind():
    ind = myind.MyIndividual()
    ind.genotype = random_genotype(constants.GEN_SIZE)
    ind.archive_data("birth_time.txt", time.time())
    return ind

class InitializationTask(dexen.InitTask):
    def __initialize__(self):
        initial_size = constants.POP_SIZE * 2
        inds = []
        for _ in range(initial_size):
            inds.append(generate_ind())
        return inds